package cn.ecut.dzy.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

/**
 * @program: JavaSEDemo
 * @description:
 * @author: DingZhenYun
 * @create: 2021-10-13 11:16
 **/

public class Test {
    public static void main(String[] args) {
        List<User> list=new ArrayList<User>();
        User user1=new User();
        user1.setName("11");
        User user2=new User();
        user1.setName("22");
        User user3=new User();
        user1.setName("33");
        User user4=new User();

        list.add(user1);
        list.add(user2);
        list.add(user3);

        list.add(user4);

        Optional<String> first = list.stream().filter(Objects::nonNull).map(User::getName).filter("33"::equals).findFirst();
        System.out.println(first);
    }
}
